/***************************************************************************
 *   Copyright (C) 2007 by Gaetano Mendola  *
 *   mendola@bigfoot.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "stat.h"
#include "modifier.h"

namespace Stats {

Stat::Stat(type_value aValue, StatType aType)
:theInitialValue(aValue),
 theType(aType),
 theModifiers()
{
}


Stat::~Stat()
{
}


Stat::operator type_value() const {
    type_value myValue = theInitialValue;

    Modifiers::const_iterator it = theModifiers.begin();
    Modifiers::const_iterator it_end = theModifiers.end();

    for ( /*void*/; it != it_end; ++it ) {
        (*it)->modify(myValue);
        myValue /= 1000;    //All Modifiers have a * 1000 to increase the resolution
    }

    return myValue;
}

void Stat::addModifier(const Modifier* aModifier) 
{
    theModifiers.push_back(aModifier);
}

void Stat::removeModifier(const Modifier* aModifier)
{
    theModifiers.remove(aModifier);
}

}
